<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
</head>
<body style=" overflow-x:hidden;" >
<div class="layui-container">

    <form class="layui-row layui-form">

            <fieldset class="layui-elem-field" style="margin-top: 20px;">
                <legend>部门详细信息</legend>


                <div class="layui-form-item">
                    <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><span style="color: red;">*</span>部门名称</label>
                    <div class="layui-input-inline" style="width:150px">
                        <input   type="text" name="name"  required lay-verify="required" placeholder="请输入"  class="layui-input" id="bmmc"  >
                        <input   type="hidden" name="bumenid" id="bumenid" >
                        <input   type="hidden" name="fjdid" id="fjdid"  >
                    </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 90px;"><span style="color: red;">*</span>负责人</label>
                        <div class="layui-input-inline" style="width:150px">
                            <input   type="text" name="fzr"  required lay-verify="required" placeholder="请输入"  class="layui-input" id="fzr" >
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><span style="color: red;">*</span>联系方式</label>
                        <div class="layui-input-inline" style="width:150px">
                            <input   type="text" name="lxfs"  required lay-verify="required" placeholder="请输入"  class="layui-input" id="lxfs" >
                        </div>
                    </div>

                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;">部门简介</label>

                            <div class="layui-input-block" >
                              <textarea style="height: 200px;width:440px" placeholder="请输入内容" class="layui-textarea" id="bmjj" name="bmjj"></textarea>
                            </div>
                    </div>
                </div>
            </fieldset>

        <button type="button" class="layui-btn layui-btn-normal"  id="modiInfo" style="width: 15%; position: absolute;left: 55%" >修改信息</button>
        <button id="modiSub" class="layui-btn layui-btn-normal layui-btn-disabled" disabled lay-submit lay-filter="update" style="width: 15%; position: absolute;left: 30%"  >立即提交</button>
    </form>

</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script>
    layui.use(['form','layer'],function () {

        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;

        $(".layui-input").addClass("layui-disabled");
        $(".layui-input").attr("disabled",true);

        $("textarea").addClass("layui-disabled");
        $("textarea").attr("disabled",true);

        $("#modiInfo").on('click',function(){
            $(".layui-input").removeClass("layui-disabled");
            $(".layui-input").attr("disabled",false);
            $("#modiSub").removeClass("layui-btn-disabled");
            $("#modiSub").removeAttr("disabled");
            $("#modiInfo").addClass("layui-btn-disabled");
            $("#modiInfo").attr("disabled",true);
            $("textarea").removeClass("layui-disabled");
            $("textarea").removeAttr("disabled",true);

        });
        $("#close").on('click',function(){
            console.log("close");
            //当你在iframe页面关闭自身时
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });

//判断类型



        //监听工具条

        form.on('submit(update)', function(data){
            $("input").css("border","");


            console.log("提交输出"+data);
            $.ajax({
                url: contextPath+"/dept",
                type: "PUT",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    console.log(data.field);
                    updateSuccess($,layer,res);
                    if(JSON.stringify(res[0]) == "{}"){


                        parent.$('#newDeptName').val(data.field.name);
                        parent.$('#newDeptLxfs').val(data.field.lxfs);
                        parent.$('#newDeptfzr').val(data.field.fzr);
                        parent.$('#newDeptBmjj').val(data.field.bmjj);
                        parent.$('#newDeptRes').val("1");

                    }



                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>